home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / CHIP Haziran 2001.iso / prog / share / 17 / dings_e.exe / Compiler / Include / STDDEF.H < prev    next >
C/C++ Source or Header  |  1999-11-07  |  11KB  |  374 lines

  1. /*
  2.  * stddef.h
  3.  *
  4.  * Standard type definitions provided by the C library.
  5.  *
  6.  * NOTE: This is typically supplied by GCC, but there's a small gotcha -
  7.  *       GCC's version doesn't guard typedefs via RC_INVOKED. This is
  8.  *       GCC's version, with the guard macro. Since we install this in
  9.  *       the tool include directory, it gets picked up before GCC's
  10.  *       internal include directory, and we're safe.
  11.  *
  12.  * This file is part of the Mingw32 package.
  13.  *
  14.  * Contributors:
  15.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  16.  *
  17.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  18.  *
  19.  *  This source code is offered for use in the public domain. You may
  20.  *  use, modify or distribute it freely.
  21.  *
  22.  *  This code is distributed in the hope that it will be useful but
  23.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  24.  *  DISCLAMED. This includes but is not limited to warranties of
  25.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  26.  *
  27.  */
  28.  
  29. #if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \
  30.      && !defined(__STDDEF_H__)) \
  31.     || defined(__need_wchar_t) || defined(__need_size_t) \
  32.     || defined(__need_ptrdiff_t) || defined(__need_NULL) \
  33.     || defined(__need_wint_t)
  34.  
  35. /* Any one of these symbols __need_* means that GNU libc
  36.    wants us just to define one data type.  So don't define
  37.    the symbols that indicate this file's entire job has been done.  */
  38. #if (!defined(__need_wchar_t) && !defined(__need_size_t)    \
  39.      && !defined(__need_ptrdiff_t) && !defined(__need_NULL)    \
  40.      && !defined(__need_wint_t))
  41. #define _STDDEF_H
  42. #define _STDDEF_H_
  43. /* snaroff@next.com says the NeXT needs this.  */
  44. #define _ANSI_STDDEF_H
  45. /* Irix 5.1 needs this.  */
  46. #define __STDDEF_H__
  47. #endif
  48.  
  49. #ifndef RC_INVOKED
  50.  
  51. #ifndef __sys_stdtypes_h
  52. /* This avoids lossage on SunOS but only if stdtypes.h comes first.
  53.    There's no way to win with the other order!  Sun lossage.  */
  54.  
  55. /* On 4.3bsd-net2, make sure ansi.h is included, so we have
  56.    one less case to deal with in the following.  */
  57. #if defined (__BSD_NET2__) || defined (____386BSD____) || defined (__FreeBSD__) || defined(__NetBSD__)
  58. #include <machine/ansi.h>
  59. #endif
  60.  
  61. /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
  62.    defined if the corresponding type is *not* defined.
  63.    FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_ */
  64. #if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_)
  65. #if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)
  66. #define _SIZE_T
  67. #endif
  68. #if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)
  69. #define _PTRDIFF_T
  70. #endif
  71. /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
  72.    instead of _WCHAR_T_. */
  73. #if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)
  74. #ifndef _BSD_WCHAR_T_
  75. #define _WCHAR_T
  76. #endif
  77. #endif
  78. /* Undef _FOO_T_ if we are supposed to define foo_t.  */
  79. #if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
  80. #undef _PTRDIFF_T_
  81. #undef _BSD_PTRDIFF_T_
  82. #endif
  83. #if defined (__need_size_t) || defined (_STDDEF_H_)
  84. #undef _SIZE_T_
  85. #undef _BSD_SIZE_T_
  86. #endif
  87. #if defined (__need_wchar_t) || defined (_STDDEF_H_)
  88. #undef _WCHAR_T_
  89. #undef _BSD_WCHAR_T_
  90. #endif
  91. #endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) */
  92.  
  93. /* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
  94.    Just ignore it.  */
  95. #if defined (__sequent__) && defined (_PTRDIFF_T_)
  96. #undef _PTRDIFF_T_
  97. #endif
  98.  
  99. /* On VxWorks, <type/vxTypesBase.h> may have defined macros like
  100.    _TYPE_size_t which will typedef size_t.  fixincludes patched the
  101.    vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
  102.    not defined, and so that defining this macro defines _GCC_SIZE_T.
  103.    If we find that the macros are still defined at this point, we must
  104.    invoke them so that the type is defined as expected.  */
  105. #if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))
  106. _TYPE_ptrdiff_t;
  107. #undef _TYPE_ptrdiff_t
  108. #endif
  109. #if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))
  110. _TYPE_size_t;
  111. #undef _TYPE_size_t
  112. #endif
  113. #if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))
  114. _TYPE_wchar_t;
  115. #undef _TYPE_wchar_t
  116. #endif
  117.  
  118. /* In case nobody has defined these types, but we aren't running under
  119.    GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and
  120.    __WCHAR_TYPE__ have reasonable values.  This can happen if the
  121.    parts of GCC is compiled by an older compiler, that actually
  122.    include gstddef.h, such as collect2.  */
  123.  
  124. /* Signed type of difference of two pointers.  */
  125.  
  126. /* Define this type if we are doing the whole job,
  127.    or if we want this type in particular.  */
  128. #if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
  129. #ifndef _PTRDIFF_T    /* in case <sys/types.h> has defined it. */
  130. #ifndef _T_PTRDIFF_
  131. #ifndef _T_PTRDIFF
  132. #ifndef __PTRDIFF_T
  133. #ifndef _PTRDIFF_T_
  134. #ifndef _BSD_PTRDIFF_T_
  135. #ifndef ___int_ptrdiff_t_h
  136. #ifndef _GCC_PTRDIFF_T
  137. #define _PTRDIFF_T
  138. #define _T_PTRDIFF_
  139. #define _T_PTRDIFF
  140. #define __PTRDIFF_T
  141. #define _PTRDIFF_T_
  142. #define _BSD_PTRDIFF_T_
  143. #define ___int_ptrdiff_t_h
  144. #define _GCC_PTRDIFF_T
  145. #ifndef __PTRDIFF_TYPE__
  146. #define __PTRDIFF_TYPE__ long int
  147. #endif
  148. typedef __PTRDIFF_TYPE__ ptrdiff_t;
  149. #endif /* _GCC_PTRDIFF_T */
  150. #endif /* ___int_ptrdiff_t_h */
  151. #endif /* _BSD_PTRDIFF_T_ */
  152. #endif /* _PTRDIFF_T_ */
  153. #endif /* __PTRDIFF_T */
  154. #endif /* _T_PTRDIFF */
  155. #endif /* _T_PTRDIFF_ */
  156. #endif /* _PTRDIFF_T */
  157.  
  158. /* If this symbol has done its job, get rid of it.  */
  159. #undef    __need_ptrdiff_t
  160.  
  161. #endif /* _STDDEF_H or __need_ptrdiff_t.  */
  162.  
  163. /* Unsigned type of `sizeof' something.  */
  164.  
  165. /* Define this type if we are doing the whole job,
  166.    or if we want this type in particular.  */
  167. #if defined (_STDDEF_H) || defined (__need_size_t)
  168. #ifndef __size_t__    /* BeOS */
  169. #ifndef _SIZE_T    /* in case <sys/types.h> has defined it. */
  170. #ifndef _SYS_SIZE_T_H
  171. #ifndef _T_SIZE_
  172. #ifndef _T_SIZE
  173. #ifndef __SIZE_T
  174. #ifndef _SIZE_T_
  175. #ifndef _BSD_SIZE_T_
  176. #ifndef _SIZE_T_DEFINED_
  177. #ifndef _SIZE_T_DEFINED
  178. #ifndef ___int_size_t_h
  179. #ifndef _GCC_SIZE_T
  180. #ifndef _SIZET_
  181. #ifndef __size_t
  182. #define __size_t__    /* BeOS */
  183. #define _SIZE_T
  184. #define _SYS_SIZE_T_H
  185. #define _T_SIZE_
  186. #define _T_SIZE
  187. #define __SIZE_T
  188. #define _SIZE_T_
  189. #define _BSD_SIZE_T_
  190. #define _SIZE_T_DEFINED_
  191. #define _SIZE_T_DEFINED
  192. #define ___int_size_t_h
  193. #define _GCC_SIZE_T
  194. #define _SIZET_
  195. #define __size_t
  196. #ifndef __SIZE_TYPE__
  197. #define __SIZE_TYPE__ long unsigned int
  198. #endif
  199. #if !(defined (__GNUG__) && defined (size_t))
  200. typedef __SIZE_TYPE__ size_t;
  201. #ifdef __BEOS__
  202. typedef long ssize_t;
  203. #endif /* __BEOS__ */
  204. #endif /* !(defined (__GNUG__) && defined (size_t)) */
  205. #endif /* __size_t */
  206. #endif /* _SIZET_ */
  207. #endif /* _GCC_SIZE_T */
  208. #endif /* ___int_size_t_h */
  209. #endif /* _SIZE_T_DEFINED */
  210. #endif /* _SIZE_T_DEFINED_ */
  211. #endif /* _BSD_SIZE_T_ */
  212. #endif /* _SIZE_T_ */
  213. #endif /* __SIZE_T */
  214. #endif /* _T_SIZE */
  215. #endif /* _T_SIZE_ */
  216. #endif /* _SYS_SIZE_T_H */
  217. #endif /* _SIZE_T */
  218. #endif /* __size_t__ */
  219. #undef    __need_size_t
  220. #endif /* _STDDEF_H or __need_size_t.  */
  221.  
  222. /* Wide character type.
  223.    Locale-writers should change this as necessary to
  224.    be big enough to hold unique values not between 0 and 127,
  225.    and not (wchar_t) -1, for each defined multibyte character.  */
  226.  
  227. /* Define this type if we are doing the whole job,
  228.    or if we want this type in particular.  */
  229. #if defined (_STDDEF_H) || defined (__need_wchar_t)
  230. #ifndef __wchar_t__    /* BeOS */
  231. #ifndef _WCHAR_T
  232. #ifndef _T_WCHAR_
  233. #ifndef _T_WCHAR
  234. #ifndef __WCHAR_T
  235. #ifndef _WCHAR_T_
  236. #ifndef _BSD_WCHAR_T_
  237. #ifndef _WCHAR_T_DEFINED_
  238. #ifndef _WCHAR_T_DEFINED
  239. #ifndef _WCHAR_T_H
  240. #ifndef ___int_wchar_t_h
  241. #ifndef __INT_WCHAR_T_H
  242. #ifndef _GCC_WCHAR_T
  243. #define __wchar_t__    /* BeOS */
  244. #define _WCHAR_T
  245. #define _T_WCHAR_
  246. #define _T_WCHAR
  247. #define __WCHAR_T
  248. #define _WCHAR_T_
  249. #define _BSD_WCHAR_T_
  250. #define _WCHAR_T_DEFINED_
  251. #define _WCHAR_T_DEFINED
  252. #define _WCHAR_T_H
  253. #define ___int_wchar_t_h
  254. #define __INT_WCHAR_T_H
  255. #define _GCC_WCHAR_T
  256.  
  257. /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
  258.    instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
  259.    symbols in the _FOO_T_ family, stays defined even after its
  260.    corresponding type is defined).  If we define wchar_t, then we
  261.    must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if
  262.    we undef _WCHAR_T_, then we must also define rune_t, since 
  263.    headers like runetype.h assume that if machine/ansi.h is included,
  264.    and _BSD_WCHAR_T_ is not defined, then rune_t is available.
  265.    machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of
  266.    the same type." */
  267. #ifdef _BSD_WCHAR_T_
  268. #undef _BSD_WCHAR_T_
  269. #ifdef _BSD_RUNE_T_
  270. #if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
  271. typedef _BSD_RUNE_T_ rune_t;
  272. #endif
  273. #endif
  274. #endif
  275.  
  276. #ifndef __WCHAR_TYPE__
  277. #ifdef __BEOS__
  278. #define __WCHAR_TYPE__ unsigned char
  279. #else
  280. #define __WCHAR_TYPE__ int
  281. #endif
  282. #endif
  283. #ifndef __cplusplus
  284. typedef __WCHAR_TYPE__ wchar_t;
  285. #endif
  286. #endif
  287. #endif
  288. #endif
  289. #endif
  290. #endif
  291. #endif
  292. #endif
  293. #endif
  294. #endif
  295. #endif
  296. #endif
  297. #endif
  298. #endif /* __wchar_t__ */
  299. #undef    __need_wchar_t
  300. #endif /* _STDDEF_H or __need_wchar_t.  */
  301.  
  302. #if defined (_STDDEF_H) || defined (__need_wint_t)
  303. #ifndef _WINT_T
  304. #define _WINT_T
  305.  
  306. #ifndef __WINT_TYPE__
  307. #define __WINT_TYPE__ unsigned int
  308. #endif
  309. typedef __WINT_TYPE__ wint_t;
  310. #endif
  311. #undef __need_wint_t
  312. #endif
  313.  
  314. /*  In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
  315.     are already defined.  */
  316. /*  BSD/OS 3.1 requires the MACHINE_ANSI_H check here.  FreeBSD 2.x apparently
  317.     does not, even though there is a check for MACHINE_ANSI_H above.  */
  318. #if defined(_ANSI_H_) || (defined(__bsdi__) && defined(_MACHINE_ANSI_H_))
  319. /*  The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
  320.     are probably typos and should be removed before 2.8 is released.  */
  321. #ifdef _GCC_PTRDIFF_T_
  322. #undef _PTRDIFF_T_
  323. #undef _BSD_PTRDIFF_T_
  324. #endif
  325. #ifdef _GCC_SIZE_T_
  326. #undef _SIZE_T_
  327. #undef _BSD_SIZE_T_
  328. #endif
  329. #ifdef _GCC_WCHAR_T_
  330. #undef _WCHAR_T_
  331. #undef _BSD_WCHAR_T_
  332. #endif
  333. /*  The following ones are the real ones.  */
  334. #ifdef _GCC_PTRDIFF_T
  335. #undef _PTRDIFF_T_
  336. #undef _BSD_PTRDIFF_T_
  337. #endif
  338. #ifdef _GCC_SIZE_T
  339. #undef _SIZE_T_
  340. #undef _BSD_SIZE_T_
  341. #endif
  342. #ifdef _GCC_WCHAR_T
  343. #undef _WCHAR_T_
  344. #undef _BSD_WCHAR_T_
  345. #endif
  346. #endif /* _ANSI_H_ || ( __bsdi__ && _MACHINE_ANSI_H_ ) */
  347.  
  348. #endif /* __sys_stdtypes_h */
  349.  
  350. #endif /* RC_INVOKED */
  351.  
  352. /* A null pointer constant.  */
  353.  
  354. #if defined (_STDDEF_H) || defined (__need_NULL)
  355. #undef NULL        /* in case <stdio.h> has defined it. */
  356. #ifdef __GNUG__
  357. #define NULL __null
  358. #else   /* G++ */
  359. #define NULL ((void *)0)
  360. #endif  /* G++ */
  361. #endif    /* NULL not defined and <stddef.h> or need NULL.  */
  362. #undef    __need_NULL
  363.  
  364. #ifdef _STDDEF_H
  365.  
  366. /* Offset of member MEMBER in a struct of type TYPE.  */
  367.  
  368. #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
  369.  
  370. #endif /* _STDDEF_H was defined this time */
  371.  
  372. #endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__
  373.       || __need_XXX was not defined before */
  374.